home *** CD-ROM | disk | FTP | other *** search
- import java.util.Calendar;
- import javax.microedition.lcdui.Alert;
- import javax.microedition.lcdui.AlertType;
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.DateField;
- import javax.microedition.lcdui.Display;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Form;
- import javax.microedition.lcdui.Image;
- import javax.microedition.lcdui.StringItem;
-
- class InputForm extends Form implements CommandListener {
- Datum midlet;
- Alert alert;
- Calendar cal1 = Calendar.getInstance();
- Calendar cal2 = Calendar.getInstance();
- DateField datum1 = new DateField("Datum1: ", 3);
- DateField datum2;
- StringItem stringItem;
- Command cancelCommand = new Command("Abbruch", 3, 0);
- Command calcCommand = new Command("Rechne", 1, 1);
- Image logo;
- Image error;
-
- InputForm(String titel) {
- super(titel);
-
- try {
- this.logo = Image.createImage("/images/logo_max.png");
- this.error = Image.createImage("/images/error.png");
- } catch (Exception var3) {
- }
-
- this.stringItem = new StringItem("Ergebnis:", "berechne alles");
- this.alert = new Alert("FEHLER", "Fehler", this.error, AlertType.ERROR);
- ((Form)this).append(this.logo);
- ((Form)this).append(this.datum1);
- ((Form)this).append(this.stringItem);
- ((Displayable)this).addCommand(this.cancelCommand);
- ((Displayable)this).addCommand(this.calcCommand);
- ((Displayable)this).setCommandListener(this);
- }
-
- public void commandAction(Command cmd, Displayable disp) {
- if (cmd == this.calcCommand) {
- String erg = null;
- CalendarCalc cc = null;
- this.cal1.setTime(this.datum1.getDate());
-
- try {
- cc = new CalendarCalc(this.cal1.get(1), this.cal1.get(2) + 1, this.cal1.get(5), this.cal1.get(11), this.cal1.get(12));
- erg = cc.getResultString();
- } catch (Exception var6) {
- this.alert.setString("Bitte nur g├╝ltige Werte eingeben!");
- Display.getDisplay(this.midlet).setCurrent(this.alert);
- }
-
- this.stringItem.setText(erg);
- } else if (cmd == this.cancelCommand) {
- this.midlet.viewStartForm();
- }
-
- }
-
- public void setMidlet(Datum m) {
- this.midlet = m;
- }
- }
-